/**
 * Created by Brant on 2016/12/28.
 */
/**
 * Created by Brant on 2016/12/28.
 */
module.exports = function ($scope,caseBarDetailZhengService,$cookies,httpservice,$rootScope,paginationService) {//caseBarDetailjinchengService
  $rootScope.showCaseDiv = false;
  //todo 监听广播，刷新列表
  $scope.$on('refreshEvidenceTask', function (event, data) {
    var caseId = $cookies.get('caseAppId');

    //刷新证据组
    $scope.getEGroupList();
    //刷新证据池子
    $scope.getEPollListFF();
  });

    /*登录ID*/
    $scope.loginId = kbt.decrypt($cookies.get('cookieUserId'));
    //获取点击的案件的id
    var caseId = $cookies.get('caseAppId');
    //获取点击的案件的type
    $scope.type = $cookies.get('type');
    //去用户的名字
    $scope.userPortraitName=$cookies.get('userPortraitName');

    $scope.focus =0;//证据组 默认选中第一个

    //证据类型列表,搜索前边的
    $scope.ETypeList = '';
    $scope.pageSize = 10;
    //获取证据组列表接口
    $scope.EGroupList = '';
    //证据组的名字
    $scope.EGName = '';
    //证据组的描素
    $scope.EGDescription = '';
    //删除证据组的ID
    $scope.deleteEGroupId = '';

    //获取证据池列表接口
    $scope.EPollList = '';

    //添加证据组
    $scope.addEGText = '';
    $scope.addEGTitle = '';
    //快速创建
    $scope.quickAddInput = '';

    //证据组ID
    $scope.evidenceGroupId = '1';
    //修改证据组的id
    $scope.updateGroupId = '';
    //证据的ID
    $scope.evidenceID = '';
    //证据清单
    $scope.eInventory = '';

    //详情
    $scope.detailUser = '';//图片
    $scope.detailFJ = '';//下载的附件
    $scope.detailData = '';//data
    $scope.detailEGName = '';//证据组名字
    $scope.veiHeaderImageUrl = '';//头像
    //修改证据组的名字
    $scope.updateEGName = '';
    $scope.clickLi = '';

    //评论
    $scope.plData = '';
    //日志
    $scope.zrData = '';
    //发送评论
    $scope.commentInput = '';
    //详情修改详情
    $scope.updateDetailXInput = '';
    //详情修改备注
    $scope.updateDetailBInput = '';

    //记录是重命名还是添加证据组
    $scope.addOrUpdataName = '1';//1是添加,2是重命名

    //获取的律师的成员
    $scope.CaseLawyerTianSelect = '';

    //添加律师成员的taskId
    $scope.addLSTaskId = '';
    //未分组证据
    $scope.evidenceNot = true;

    $scope.caseAppName = $cookies.get('caseAppName');

    $scope.pageSetting3 = paginationService.getDefaultPageSetting();

    //获取证据类型列表,搜索前边的
    $scope.getETypeList = function () {
        caseBarDetailZhengService.getETypeList().then(function (data) {
            if (data.code == 1) {
                $scope.ETypeList = data.data;
            }
        })
    };
    $scope.getETypeList();

    //获取证据组列表接口
    $scope.getEGroupList = function () {
      caseBarDetailZhengService.getEGroupList(caseId).then(function (data) {
        if (data.code == 1) {
          $scope.EGroupList = data.data;
        }
      })
    };
    $scope.getEGroupList();

    //添加证据组或者修改证据组名字
    $scope.addEGroup = function () {


    if ($scope.addOrUpdataName == '1') {

      $rootScope.loadingShow = true;
      $rootScope.fadeShow = true;
      //添加
      caseBarDetailZhengService.addEGroup(caseId, $scope.addEGText, $scope.addEGTitle, $scope.loginId).then(function (data) {
        $rootScope.loadingShow = false;
        $rootScope.fadeShow = false;
        if (data.code == 1) {


          //刷新证据组列表
          $scope.getEGroupList();
          $scope.addEGTitle = '';
          $scope.addEGText = '';

          $('.createEvidence').fadeOut();


        }
      })
    } else {
      $rootScope.loadingShow = true;
      $rootScope.fadeShow = true;
      //修改
      caseBarDetailZhengService.updateEGroupName($scope.updateGroupId, $scope.addEGTitle, $scope.addEGText, $scope.loginId).then(function (data) {
        $rootScope.loadingShow = false;
        $rootScope.fadeShow = false;
        if (data.code == 1) {
          $scope.addEGTitle = '';
          $scope.addEGText = '';
          //刷新证据组列表
          $scope.getEGroupList();
          $('.createEvidence').fadeOut();
        }
      });
    }

  };


//
//
//     //获取证据列表
    $scope.getEPollListFF = function () {
        var isAll = false;
        if($scope.evidenceGroupId == 1){//isAll：未分组（2）、全部（1）--1、
            isAll = "1";
        }else if($scope.evidenceGroupId == 2){
            isAll = "0";
        }else {
          isAll = 0
        }
        $rootScope.loadingShow = true;
        $rootScope.fadeShow = true;
        caseBarDetailZhengService.getEPollList(caseId, $scope.evidenceGroupId,isAll,$scope.pageSetting3.pageNo,$scope.pageSetting3.pageSize).then(function (data) {
            $rootScope.loadingShow = false;
            $rootScope.fadeShow = false;
            if (data.code == 1) {
                $scope.EPollList = data.data;
              // 添加证据组 top 值 计算
              var baseHeight=$(".L_caseBarZhengL").height()-$('#add-zjz-hide').height()-2+'px';
              $('#add-zjz-hide').css("top",baseHeight);

                $scope.pageSetting3.totalItems = data.totalCount;
                //$(this).css('border-left', '3px solid #00BB9C');
                $(".unGroupEvidenceP").css('border-left', '0px solid #00BB9C');
                //$(this).siblings().css('border-left', '1px solid rgb(215,225,232)');
                $('.bodyTow .center').css('display', 'none');
                $('.bodyTow .haveEviCenter').css('display', 'block');

                //修改证据类型的名字
                for (var i = 0; i < data.data.length; i++) {
                    for (var j = 0; j < $scope.ETypeList.length; j++) {
                        if ($scope.EPollList[i].task.evidenceTypeId == $scope.ETypeList[j].evidenceTypeCode) {
                             $scope.EPollList[i].task.evidenceTypeIdName = $scope.ETypeList[j].evidenceTypeName;
                        }
                    }
                };
              //分页
              $scope.totalPage = data.totalPage;//总页数
              $scope.totalCount = data.totalCount;//总条数
              $scope.beginPage = data.beginPage;//开始页
              $scope.endPage = data.endPage;//结束页
              /*设置其他页码颜色*/
              $('.select').css('color', '#666');
              $(".pagCenter").show();
              $('.caseBar_kong').hide();
              $('.caseBar_list').show();
              $('.select').css('color', '#666');
              //   $scope.newXin_1Date = data.data;

              /*声明一个数组显示页数*/
              $scope.arrPage = new Array();
              for (var j = 0; j < $scope.totalCount-$scope.pageSize*j; j++) {
                $scope.arrPage[j] = j + 1;
                // vm.filterBackParams = vm.filterBackParams.splice(0,10*j);
              }

              // $scope.pageNow = pageNum;
              // setTimeout(function () {
              //   $('.select' + pageNum).css('color', 'red');
              // }, 50);


            }
        })
    };
    $scope.getEPollListFF();
    //过滤
    $scope.evidenceTypeIdNameLi=function (input){
      for (var j = 0; j < $scope.ETypeList.length; j++) {
        if (input== $scope.ETypeList[j].evidenceTypeCode) {
          input = $scope.ETypeList[j].evidenceTypeName;
        }
      }
      return input;
    }
    //获取证据池的内容
    $scope.getEPoll = function (id, $event, text, description ,i) {

      // var event = $event.target;
      // var e = $(event);
      $scope.evidenceNot = false;
      //给证据组的名字赋值
      $scope.EGName = text;
      $scope.EGDescription = description;

      $scope.focus = i;//证据组 选中样式

      // $(e).css('border-left', '3px solid #5dc2ae');
      // $(e).parents('.allEvidence').siblings('').children('p').css('border-left', '0px solid #5dc2ae');

      //给证据组id赋值
      $scope.evidenceGroupId = id;

      $scope.getEPollListFF();
    };


    //生成证据清单
    $scope.showEAllList = function () {
        caseBarDetailZhengService.getEAllList(caseId).then(function (data) {
            var files = new Blob([data]);
            var link = document.createElement('a');
            link.href = URL.createObjectURL(files);
            link.download = '证据清单.xls';
            link.click();
            window.URL.revokeObjectURL(link.href);
            /*// if(data.code == 1){
                $scope.eInventory = data.date;
                //设置证据类型
                for (var i = 0;i<$scope.eInventory.length;i++){

                    for (var j=0;j<$scope.eInventory[i].evidence.length;j++){
                        for (var s=0;s<$scope.ETypeList.length;s++){
                            if($scope.eInventory[i].evidence[j].evidenceTypeId == $scope.ETypeList[s].evidenceTypeCode){
                                $scope.eInventory[i].evidence[j].evidenceTypeId = $scope.ETypeList[s].evidenceTypeName;
                            }
                        }
                    }

                }
            // table 表格循环
                var table='';
                $('.evidenceDoct').html('');
                for(var i=0;i<$scope.eInventory.length;i++){
                    table +="<tr>";

                    var evidenceDoctTdHeight = $scope.eInventory[i].evidence.length;
                    if(evidenceDoctTdHeight == 1){
                        table +="<td class='width15 pull-left evidenceDoctTd evidenceDoctTd1' rowspan="+$scope.eInventory[i].evidence.length+">"+$scope.eInventory[i].evidenceGroupName+"</td>";
                        table +="<td class='width15 pull-left evidenceDoctTd evidenceDoctTd1' rowspan="+$scope.eInventory[i].evidence.length+">"+$scope.eInventory[i].description+"</td>";
                    }else if(evidenceDoctTdHeight == 2){
                        table +="<td class='width15 pull-left evidenceDoctTd evidenceDoctTd2' rowspan="+$scope.eInventory[i].evidence.length+">"+$scope.eInventory[i].evidenceGroupName+"</td>";
                        table +="<td class='width15 pull-left evidenceDoctTd evidenceDoctTd2' rowspan="+$scope.eInventory[i].evidence.length+">"+$scope.eInventory[i].description+"</td>";
                    }else if(evidenceDoctTdHeight == 3){
                        table +="<td class='width15 pull-left evidenceDoctTd evidenceDoctTd3' rowspan="+$scope.eInventory[i].evidence.length+">"+$scope.eInventory[i].evidenceGroupName+"</td>";
                        table +="<td class='width15 pull-left evidenceDoctTd evidenceDoctTd3' rowspan="+$scope.eInventory[i].evidence.length+">"+$scope.eInventory[i].description+"</td>";
                    }else if(evidenceDoctTdHeight == 4){
                        table +="<td class='width15 pull-left evidenceDoctTd evidenceDoctTd4' rowspan="+$scope.eInventory[i].evidence.length+">"+$scope.eInventory[i].evidenceGroupName+"</td>";
                        table +="<td class='width15 pull-left evidenceDoctTd evidenceDoctTd4' rowspan="+$scope.eInventory[i].evidence.length+">"+$scope.eInventory[i].description+"</td>";
                    }else if(evidenceDoctTdHeight == 5){
                        table +="<td class='width15 pull-left evidenceDoctTd evidenceDoctTd5' rowspan="+$scope.eInventory[i].evidence.length+">"+$scope.eInventory[i].evidenceGroupName+"</td>";
                        table +="<td class='width15 pull-left evidenceDoctTd evidenceDoctTd5' rowspan="+$scope.eInventory[i].evidence.length+">"+$scope.eInventory[i].description+"</td>";
                    }else if(evidenceDoctTdHeight == 6){
                        table +="<td class='width15 pull-left evidenceDoctTd evidenceDoctTd6' rowspan="+$scope.eInventory[i].evidence.length+">"+$scope.eInventory[i].evidenceGroupName+"</td>";
                        table +="<td class='width15 pull-left evidenceDoctTd evidenceDoctTd6' rowspan="+$scope.eInventory[i].evidence.length+">"+$scope.eInventory[i].description+"</td>";
                    }else if(evidenceDoctTdHeight == 7){
                        table +="<td class='width15 pull-left evidenceDoctTd evidenceDoctTd7' rowspan="+$scope.eInventory[i].evidence.length+">"+$scope.eInventory[i].evidenceGroupName+"</td>";
                        table +="<td class='width15 pull-left evidenceDoctTd evidenceDoctTd7' rowspan="+$scope.eInventory[i].evidence.length+">"+$scope.eInventory[i].description+"</td>";
                    }else if(evidenceDoctTdHeight == 8){
                        table +="<td class='width15 pull-left evidenceDoctTd evidenceDoctTd8' rowspan="+$scope.eInventory[i].evidence.length+">"+$scope.eInventory[i].evidenceGroupName+"</td>";
                        table +="<td class='width15 pull-left evidenceDoctTd evidenceDoctTd8' rowspan="+$scope.eInventory[i].evidence.length+">"+$scope.eInventory[i].description+"</td>";
                    }else if(evidenceDoctTdHeight == 9){
                        table +="<td class='width15 pull-left evidenceDoctTd evidenceDoctTd9' rowspan="+$scope.eInventory[i].evidence.length+">"+$scope.eInventory[i].evidenceGroupName+"</td>";
                        table +="<td class='width15 pull-left evidenceDoctTd evidenceDoctTd9' rowspan="+$scope.eInventory[i].evidence.length+">"+$scope.eInventory[i].description+"</td>";
                    }else if(evidenceDoctTdHeight == 10){
                        table +="<td class='width15 pull-left evidenceDoctTd evidenceDoctTd10' rowspan="+$scope.eInventory[i].evidence.length+">"+$scope.eInventory[i].evidenceGroupName+"</td>";
                        table +="<td class='width15 pull-left evidenceDoctTd evidenceDoctTd10' rowspan="+$scope.eInventory[i].evidence.length+">"+$scope.eInventory[i].description+"</td>";
                    }else if(evidenceDoctTdHeight == 11){
                        table +="<td class='width15 pull-left evidenceDoctTd evidenceDoctTd11' rowspan="+$scope.eInventory[i].evidence.length+">"+$scope.eInventory[i].evidenceGroupName+"</td>";
                        table +="<td class='width15 pull-left evidenceDoctTd evidenceDoctTd11' rowspan="+$scope.eInventory[i].evidence.length+">"+$scope.eInventory[i].description+"</td>";
                    }else if(evidenceDoctTdHeight == 12){
                        table +="<td class='width15 pull-left evidenceDoctTd evidenceDoctTd12' rowspan="+$scope.eInventory[i].evidence.length+">"+$scope.eInventory[i].evidenceGroupName+"</td>";
                        table +="<td class='width15 pull-left evidenceDoctTd evidenceDoctTd12' rowspan="+$scope.eInventory[i].evidence.length+">"+$scope.eInventory[i].description+"</td>";
                    }else if(evidenceDoctTdHeight == 13){
                        table +="<td class='width15 pull-left evidenceDoctTd evidenceDoctTd13' rowspan="+$scope.eInventory[i].evidence.length+">"+$scope.eInventory[i].evidenceGroupName+"</td>";
                        table +="<td class='width15 pull-left evidenceDoctTd evidenceDoctTd13' rowspan="+$scope.eInventory[i].evidence.length+">"+$scope.eInventory[i].description+"</td>";
                    }else if(evidenceDoctTdHeight == 14){
                        table +="<td class='width15 pull-left evidenceDoctTd evidenceDoctTd14' rowspan="+$scope.eInventory[i].evidence.length+">"+$scope.eInventory[i].evidenceGroupName+"</td>";
                        table +="<td class='width15 pull-left evidenceDoctTd evidenceDoctTd14' rowspan="+$scope.eInventory[i].evidence.length+">"+$scope.eInventory[i].description+"</td>";
                    }else if(evidenceDoctTdHeight == 15){
                        table +="<td class='width15 pull-left evidenceDoctTd evidenceDoctTd15' rowspan="+$scope.eInventory[i].evidence.length+">"+$scope.eInventory[i].evidenceGroupName+"</td>";
                        table +="<td class='width15 pull-left evidenceDoctTd evidenceDoctTd15' rowspan="+$scope.eInventory[i].evidence.length+">"+$scope.eInventory[i].description+"</td>";
                    }else if(evidenceDoctTdHeight == 16){
                        table +="<td class='width15 pull-left evidenceDoctTd evidenceDoctTd16' rowspan="+$scope.eInventory[i].evidence.length+">"+$scope.eInventory[i].evidenceGroupName+"</td>";
                        table +="<td class='width15 pull-left evidenceDoctTd evidenceDoctTd16' rowspan="+$scope.eInventory[i].evidence.length+">"+$scope.eInventory[i].description+"</td>";
                    }else if(evidenceDoctTdHeight == 17){
                        table +="<td class='width15 pull-left evidenceDoctTd evidenceDoctTd17' rowspan="+$scope.eInventory[i].evidence.length+">"+$scope.eInventory[i].evidenceGroupName+"</td>";
                        table +="<td class='width15 pull-left evidenceDoctTd evidenceDoctTd17' rowspan="+$scope.eInventory[i].evidence.length+">"+$scope.eInventory[i].description+"</td>";
                    }else if(evidenceDoctTdHeight == 18){
                        table +="<td class='width15 pull-left evidenceDoctTd evidenceDoctTd18' rowspan="+$scope.eInventory[i].evidence.length+">"+$scope.eInventory[i].evidenceGroupName+"</td>";
                        table +="<td class='width15 pull-left evidenceDoctTd evidenceDoctTd18' rowspan="+$scope.eInventory[i].evidence.length+">"+$scope.eInventory[i].description+"</td>";
                    }else if(evidenceDoctTdHeight == 19){
                        table +="<td class='width15 pull-left evidenceDoctTd evidenceDoctTd19' rowspan="+$scope.eInventory[i].evidence.length+">"+$scope.eInventory[i].evidenceGroupName+"</td>";
                        table +="<td class='width15 pull-left evidenceDoctTd evidenceDoctTd19' rowspan="+$scope.eInventory[i].evidence.length+">"+$scope.eInventory[i].description+"</td>";
                    }else if(evidenceDoctTdHeight == 20){
                        table +="<td class='width15 pull-left evidenceDoctTd evidenceDoctTd20' rowspan="+$scope.eInventory[i].evidence.length+">"+$scope.eInventory[i].evidenceGroupName+"</td>";
                        table +="<td class='width15 pull-left evidenceDoctTd evidenceDoctTd20' rowspan="+$scope.eInventory[i].evidence.length+">"+$scope.eInventory[i].description+"</td>";
                    }else if(evidenceDoctTdHeight == 21){
                        table +="<td class='width15 pull-left evidenceDoctTd evidenceDoctTd21' rowspan="+$scope.eInventory[i].evidence.length+">"+$scope.eInventory[i].evidenceGroupName+"</td>";
                        table +="<td class='width15 pull-left evidenceDoctTd evidenceDoctTd21' rowspan="+$scope.eInventory[i].evidence.length+">"+$scope.eInventory[i].description+"</td>";
                    }else if(evidenceDoctTdHeight == 22){
                        table +="<td class='width15 pull-left evidenceDoctTd evidenceDoctTd22' rowspan="+$scope.eInventory[i].evidence.length+">"+$scope.eInventory[i].evidenceGroupName+"</td>";
                        table +="<td class='width15 pull-left evidenceDoctTd evidenceDoctTd22' rowspan="+$scope.eInventory[i].evidence.length+">"+$scope.eInventory[i].description+"</td>";
                    }

                    for(var j=0;j<$scope.eInventory[i].evidence.length;j++){

                        //table +="<tr>";
                        //table +="<td class='width15 pull-left evidenceDoctTd' rowspan="+$scope.eInventory[i].evidence.length+">"+$scope.eInventory[i].evidenceGroupName+"</td>";
                        //table +="<td class='width15 pull-left evidenceDoctTd' rowspan="+$scope.eInventory[i].evidence.length+">"+$scope.eInventory[i].description+"</td>";

                        table +="<td class='width15 pull-left'>"+$scope.eInventory[i].evidence[j]
.evidenceName+"</td>";
                        if($scope.eInventory[i].evidence[j].description=='null'){
                            table +="<td class='width15 pull-left'>-</td>";
                        }else {
                            table +="<td class='width15 pull-left'>"+$scope.eInventory[i].evidence[j].description+"</td>";
                        }

                        table +="<td class='width7 pull-left'>"+$scope.eInventory[i].evidence[j]
.evidenceTypeId+"</td>";

                        if($scope.eInventory[i].evidence[j].remark == 'null' || $scope.eInventory[i].evidence[j].remark == null){
                            table +="<td class='width26 pull-left'>-</td>";
                        }else {
                            table +="<td class='width26 pull-left'>"+$scope.eInventory[i].evidence[j]
                                    .remark+"</td>";
                        }

                        table +="<td class='width7 pull-left'>-</td>";
                    }
                    table +="</tr>";
                }

                $('.evidenceDoct').append(table);

            // }*/
        });
    };
    $scope.queckAddB=function(index){
      if(index==1){
        ($scope.quickAddInput != '')&&($scope.quickAddInputT=false);
      }
      if(index==2){
        ($scope.ETypeSelect.id != '0')&&($scope.ETypeSelectI=false);
      }

      if(index==3){
        ($scope.EGroupList.id!=undefined)&&($scope.EGroupListI=false);
      }
    }
    //快速创建证据
    $scope.queckAddE = function () {
        if($scope.quickAddInput != ''){
            // $scope.eType = $('.ETypeSelect option:selected').val();
            // $scope.evidenceGroupId = $('.EGroupList option:selected').val();
            // console.log('ooo',$scope.EGroupList.id);
            //点击全部,也添加到未分组
            if ($scope.evidenceGroupId == '1') {//1：全部证据；2：未分组证据
                $scope.evidenceGroupId = '2';
            }
          $scope.quickAddInputT=false;
            if($scope.ETypeSelect.id != '0'){
              $scope.ETypeSelectI=false;
              // if($scope.EGroupList.id!=undefined){
                $scope.EGroupListI=false;
                caseBarDetailZhengService.addE(caseId, $scope.quickAddInput, $scope.loginId,$scope.ETypeSelect.id,$scope.evidenceGroupId).then(function (data) {
                  if (data.code == 1) {
                    $scope.getEGroupList();
                    $scope.getEPollListFF();
                    $('#createEvidenceModal').modal('hide');
                  }
                })
              // }else{
              //   $scope.EGroupListI=true;
              // }
            }else{
              $scope.ETypeSelectI=true;
            }

        }else{
          $scope.quickAddInputT=true;
        }


        /*else {
          bootbox.dialog({
            message: "请选择证据种类",
            title: "提示信息",
            buttons: {
              Cancel: {
                label: "取消",
                className: "btn-cancel",
                callback: function () {

                }
              },
              OK: {
                label: "确定",
                className: "btn-confirm",
                callback: function () {

                }
              }
            }
          });
        }*/

    };
//
//
//     //证据详情
//     //证据详情.点击证据的P出现
//     $scope.evidenceDetailShow = function (pClickId) {
//
//
//         //显示详情界面
//         $('.rightComeToZJ').animate({
//             "right": "0"
//         }, 300);
//
//         //让所有出现编辑的都先隐藏掉
//         $('.ztextareaAndSaveBox').css('display', 'none');
//         $('#zshuxieqisu').css('display', 'block');
//
//         $('#zqisuzhunbei1').addClass('hide');
//         $('#zqisuzhunbei').removeClass('hide');
//
//         //给证据的ID赋值
//         $scope.evidenceID = pClickId;
//         $rootScope.loadingShow = true;
//         $rootScope.fadeShow = true;
//         caseBarDetailZhengService.getEDetail(pClickId).then(function (data) {
//             $rootScope.loadingShow = false;
//             $rootScope.fadeShow = false;
//             if (data.code == 1) {
//
//                 $scope.detailData = data.data;
//                 $scope.detailFJ = data.evidenceAttached;
//                 $scope.detailUser = data.userlist;
//                 //添加执行人图片
//                 for(var i=0;i < $scope.detailUser.length;i++){
//
//                     if($scope.detailUser[i].icon == null){
//
//                     }else{
//                         $scope.detailUser[i].icon = httpservice.userHeaderImageUrl + $scope.detailUser[i].icon;
//                     }
//
//                 }
//
//
//                 //附件下载
//                 for(var i=0;i < $scope.detailFJ.length;i++){
//
//                     if($scope.detailFJ[i].filePact == null){
//
//                     }else{
//                         $scope.detailFJ[i].filePact = httpservice.userHeaderImageUrl + $scope.detailFJ[i].filePact;
//                     }
//
//                 }
//
//
//                 //给taskId赋值
//                 $scope.addLSTaskId = $scope.detailData.evidenceTask.id;
//
//                 //修改证据类型的名字
//                 var index = $scope.detailData.evidenceTypeId - 1;
//                 $('#usertype3').get(0).selectedIndex = index;
//                 $('#usertype4').get(0).selectedIndex = index;
//
//                 //详情->获取在哪个证据组
//                 $('.zEvidenceGName').val($scope.detailData.evidenceGroupId);
//
//                 //获取详情属于哪个证据组
//                 if($scope.EGroupList){
//                     for(var i = 0;i<$scope.EGroupList.length;i++){
//
//                         if($scope.detailData.evidenceGroupId == $scope.EGroupList[i].id){
//                             $scope.detailEGName = $scope.EGroupList[i].evidenceGroupName;
//                         }
//                     }
//                 }
//
//
//                 //文字带入到输入框中
//                 $('.zjdetailtextarea').val($scope.detailData.description);
//                 $('.zjdetailbz').val($scope.detailData.remark);
//
//
//             }
//         });
//         //评论
//         $scope.gerECommeng();
//     };
//
//     //详情的描述,出现编辑框
//     $scope.showTextareaBox = function ($event) {
//         if($scope.type != 7){
//             var $event = $event.target;
//             var e = $($event);
//
//             $('#zshuxieqisu').css('display', 'none');
//             $('.ztextareaAndSaveBox').css('display', 'block');
//
//             $('#zqisuzhunbei').addClass('hide');
//             $('#zqisuzhunbei1').removeClass('hide');
//         }
//
//     };
//     //隐藏详情描述
//     $scope.hideAddDetailBox = function ($event) {
//         var $event = $event.target;
//         var e = $($event);
//
//         $(e).parents('.ztextareaAndSaveBox').css('display', 'none');
//         $(e).parents('.ztextareaAndSaveBox').siblings('#zshuxieqisu').css('display', 'block');
//
//         $('#zqisuzhunbei1').addClass('hide');
//         $('#zqisuzhunbei').removeClass('hide');
//     }
//
//     //详情的备注
//     $scope.showTextareaBox1 = function ($event) {
//         if($scope.type != 7){
//             var $event = $event.target;
//             var e = $($event);
//
//             $(e).parents('#zshuxieqisu1').css('display', 'none');
//             $(e).parents('#zshuxieqisu1').siblings('.ztextareaAndSaveBox1').css('display', 'block');
//         }
//
//     };
//     //隐藏详情备注
//     $scope.hideAddDetailBox1 = function ($event) {
//         var $event = $event.target;
//         var e = $($event);
//
//         $(e).parents('.ztextareaAndSaveBox1').css('display', 'none');
//         $(e).parents('.ztextareaAndSaveBox1').siblings('#zshuxieqisu1').css('display', 'block');
//     }
//
//     //修改详情详情
//     $scope.updateDetailX = function (inputText) {
//
//         var egid = $('.zEvidenceGName option:selected').val();
//         var name = $('.zEvidenceName').val();
//         $rootScope.loadingShow = true;
//         $rootScope.fadeShow = true;
//         caseBarDetailZhengService.updateEDetail($scope.evidenceID, $scope.loginId, "1", null, inputText, null,egid,name).then(function (data) {
//             $rootScope.loadingShow = false;
//             $rootScope.fadeShow = false;
//             if (data.code == 1) {
//                 $scope.evidenceDetailShow($scope.evidenceID);
//                 $('.ztextareaAndSaveBox').css('display', 'none');
//                 $('#zshuxieqisu').css('display', 'block');
//
//                 $('#zqisuzhunbei1').addClass('hide');
//                 $('#zqisuzhunbei').removeClass('hide');
//
//                 $scope.getEPollListFF();
//                 $scope.getEGroupList();
//             }
//         });
//     }
//
//     //修改详情备注
//     $scope.updateDetailB = function (inputText) {
//         $rootScope.loadingShow = true;
//         $rootScope.fadeShow = true;
//         caseBarDetailZhengService.updateEDetail($scope.evidenceID, $scope.loginId, "1", null, null, inputText).then(function (data) {
//             $rootScope.loadingShow = false;
//             $rootScope.fadeShow = false;
//             if (data.code == 1) {
//                 //刷新详情界面
//                 $scope.evidenceDetailShow($scope.evidenceID);
//                 $('.ztextareaAndSaveBox1').css('display', 'none');
//                 $('#zshuxieqisu1').css('display', 'block');
//             }
//         });
//
//     }
//
//     //修改案件类型
//     //获取Select选择的Value
//     $("#usertype3").change(function () {
//         var courtId = $('#usertype3 option:selected').val();
//         $rootScope.loadingShow = true;
//         $rootScope.fadeShow = true;
//         caseBarDetailZhengService.updateEDetail($scope.evidenceID, $scope.loginId, "1", courtId, null, null).then(function (data) {
//             $rootScope.loadingShow = false;
//             $rootScope.fadeShow = false;
//             if (data.code == 1) {
//                 //刷新详情界面
//                 $scope.evidenceDetailShow($scope.evidenceID);
//                 //刷新证据池
//                 $scope.getEPollListFF();
//             }
//         });
//     });
//     //修改案件类型
//     //获取Select选择的Value
//     $("#usertype4").change(function () {
//         var courtId = $('#usertype4 option:selected').val();
//         caseBarDetailZhengService.updateEDetail($scope.evidenceID, $scope.loginId, "1", courtId, null, null).then(function (data) {
//             if (data.code == 1) {
//                 //刷新详情界面
//                 //$scope.evidenceDetailShow($scope.evidenceID);
//                 //刷新证据池
//                 //$scope.getEPollListFF();
//             }
//         });
//     });
//
//     //删除证据
    $scope.deleteEDetail = function () {
        $('.rightComeToZJ').animate({
            "right": "-700"
        }, 300);
    };

    $scope.zjdeleteupdateNameConfirm = function () {
        $rootScope.loadingShow = true;
        $rootScope.fadeShow = true;
        caseBarDetailZhengService.deleteEDetail($scope.evidenceID, $scope.loginId).then(function (data) {
            $rootScope.loadingShow = false;
            $rootScope.fadeShow = false;
            if (data.code == 1) {
                //刷新证据组
                $scope.getEGroupList();
                //刷新证据池子
                $scope.getEPollListFF();

                $('#zjdeletedeleteModalpanel').modal('hide');

            }
        });
    };

//
//     //最底部的评论和日志
//     //获取评论
//     $scope.gerECommeng = function () {
//         //评论接口
//         $rootScope.loadingShow = true;
//         $rootScope.fadeShow = true;
//         caseBarDetailZhengService.getEComment($scope.evidenceID).then(function (data) {
//             $rootScope.loadingShow = false;
//             $rootScope.fadeShow = false;
//             if (data.code == 1) {
//                 $scope.plData = data.data;
//
//                 //评论的图片
//                 for(var i=0;i<$scope.plData.length;i++){
//                     if($scope.plData[i].biglawuser.icon != null){
//                         $scope.plData[i].biglawuser.icon = httpservice.userHeaderImageUrl + $scope.plData[i].biglawuser.icon;
//                     }
//                 }
//             }
//         });
//     };
//     //日志
//     $scope.getELog = function () {
//         $rootScope.loadingShow = true;
//         $rootScope.fadeShow = true;
//         caseBarDetailZhengService.getELog($scope.evidenceID).then(function (data) {
//             $rootScope.loadingShow = false;
//             $rootScope.fadeShow = false;
//             if (data.code == 1) {
//                 //
//                 $scope.rzData = data.data;
//             }
//         });
//     }
//
//     //showpl
//     $scope.showPlBox = function ($event) {
//         var $event = $event.target;
//         var e = $($event);
//
//         $(e).parents('.register-navTitle').siblings('.plDiv').css('display', 'block');
//         $(e).parents('.register-navTitle').siblings('.rwrzDiv').css('display', 'none');
//         $(e).css('border-bottom', '2px solid #00BB9C');
//         $(e).siblings('.rwrz').css('border-bottom', '0px solid #00BB9C');
//
//         $('#zhalf2').css('display', 'block');
//
//         $scope.gerECommeng();
//     }
//     //showrwrz
//     $scope.showRwrzBox = function ($event) {
//         var $event = $event.target;
//         var e = $($event);
//
//         $(e).parents('.register-navTitle').siblings('.plDiv').css('display', 'none');
//         $(e).parents('.register-navTitle').siblings('.rwrzDiv').css('display', 'block');
//         $(e).css('border-bottom', '2px solid #00BB9C');
//         $(e).siblings('.pl').css('border-bottom', '0px solid #00BB9C');
//
//         $('#zhalf2').css('display', 'none');
//
//         $scope.getELog();
//     }
//
//
//     //发布评论
//     $scope.sendComment = function () {
//         $rootScope.loadingShow = true;
//         $rootScope.fadeShow = true;
//         caseBarDetailZhengService.insertEComment($scope.evidenceID, $scope.loginId, $scope.commentInput).then(function (data) {
//             $rootScope.loadingShow = false;
//             $rootScope.fadeShow = false;
//             if (data.code == 1) {
//                 $scope.gerECommeng();
//                 $scope.commentInput = '';
//
//                 //获取证据组列表
//                 $scope.getEPollListFF();
//             }
//         });
//     }
//
//
    $scope.init = function () {



        /*用于固定导航条*/
        sessionStorage.navNum = 3;

        //点击新增
        $('.footer').click(function (event) {
          var baseHeightT=$(".L_caseBarZhengL").height()-$('.createEvidence').height()-2+'px';
          $('.createEvidence').css("top",baseHeightT);
            $(this).siblings('.createEvidence').fadeIn();
            $scope.addOrUpdataName = '1';
            $('#addEGName').val('');
            $('#addEGDisp').val('');
            event.stopPropagation();
        });

        //点击添加框里边的取消
        $('.cannel').click(function () {
            $(this).parents('.createEvidence').fadeOut();
        });


        //点击Li第二个大的Body出现数据
        $('.sigleEvidence li').click(function () {
            // $(this).css('border-left','3px solid #00BB9C');
            // $(this).siblings().css('border-left','1px solid rgb(215,225,232)');
            // $('.bodyTow .center').css('display','none');
            // $('.bodyTow .haveEviCenter').css('display','block');
        });

        // 点击具体证据出现详情界面
        $('.haveEviCenter li').click(function () {
           $('.rightComeToZJ').animate({
               "right": "0"
           }, 300);

        });
        //点击X号关闭详情页面
        $('.closeDetail').click(function () {
            $(this).parents('.rightComeToZJ').animate({
                "right": "-700"
            }, 300);
        });

      // $scope.getEPollListFF();
    };

    $scope.init();

//
//     //出现添加律师成员的列表,获取请求
//     $(".addlvshi").on("click", function () {
//
//         $(".LawyerAddBody").css("display","block");
//         $rootScope.loadingShow = true;
//         $rootScope.fadeShow = true;
//         caseBarDetailZhengService.getLawyers(caseId).then(function (data) {
//             $rootScope.loadingShow = false;
//             $rootScope.fadeShow = false;
//             if (data.code == 1) {
//                 $scope.CaseLawyerTianSelect = data.data;
//             }
//         });
//
//     });
//
//
//     $(".LawyerAddBody .Add-close").on("click", function () {
//         $(".LawyerAddBody").css("display","none");
//     });
//
//     //分配给
//   $scope.PerEvidenceList = [];
//   $scope.taskEvidence = taskEvidence;
//   $scope.evidencePer = evidencePer;
//   function taskEvidence(name, id) {
//     //排除相同的律师
//     for(var i=0;i<$scope.PerEvidenceList.length; i++) {
//        if(id == $scope.PerEvidenceList[i].id) {
//           break;
//        }
//     }
//     var item = {
//       id:id,
//       name:name
//     };
//     $scope.PerEvidenceList.push(item);
//     $(".LawyerAddBody").css("display","none");
//   }
//
//   //删除--分配人员
//   function evidencePer(index) {
//     $scope.PerEvidenceList.splice(index,1);
//   }
//
//     //添加律师成员
//     $scope.CaseLawyerTianButton = function (name, id) {
//         $rootScope.loadingShow = true;
//         $rootScope.fadeShow = true;
//       caseBarDetailZhengService.addLawyers($scope.addLSTaskId, id, name, $scope.loginId, $scope.evidenceID,$scope.userPortraitName,$scope.detailData.evidenceName).then(function (data) {
//             $rootScope.loadingShow = false;
//             $rootScope.fadeShow = false;
//             if (data.code == 1) {
//               //刷新详情界面
//               $scope.evidenceDetailShow($scope.evidenceID);
//               $(".rightComeToZJ").css("display","none");
//
//               // var item = data.data;
//               // $scope.PerEvidenceList =  $scope.PerEvidenceList.push(item);
//               // $(".LawyerAddBody").css("display","none");
//             }
//         })
//     };
//     //删除律师
//     $scope.deleteLawyer = function (name, id) {
//         $rootScope.loadingShow = true;
//         $rootScope.fadeShow = true;
//         caseBarDetailZhengService.deleteLawyers($scope.addLSTaskId, id, name, $scope.loginId, $scope.evidenceID).then(function (data) {
//             $rootScope.loadingShow = false;
//             $rootScope.fadeShow = false;
//             if (data.code == 1) {
//                 //刷新详情界面
//                 $scope.evidenceDetailShow($scope.evidenceID);
//             }
//         });
//     };
//
//
    //出现修改的盒子
    $scope.showUpdateBox = function ($event, groupId, updateName) {

        event.stopPropagation();
        $('.editStageEvid').css('display','none');
        var $a = $($event.target);
        $($a).parents('.allEvidence').siblings('.editStageEvid').css('display','block');

        var $event = $event.target;
        var e = $($event);
        $scope.clickLi = e;
        $scope.updateGroupId = groupId;
        $scope.updateEGName = updateName;
        $('.titleName').css('display','block');
        $('.glyphicon').css('display','block');
        $(e).siblings('.editStageEvid').css('display', 'block');

    };

    //点击擦号删除
    $scope.removeBox = function ($event) {
        $event.stopPropagation();
        var $event = $event.target;
        var e = $($event);
        $(e).parents('.editStageEvid').css('display', 'none');
        // $(e).parents('.updateBox').siblings('input').css('display', 'none');
        // $(e).parents('.updateBox').siblings('.allEvidenceP').css('display', 'block');
    };


    //给证据组重新命名
    $scope.updateName = function ($event,name,disp) {
        $event.stopPropagation();
        var $event = $event.target;
        var e = $($event);

      // 重新命证据组 top 值 计算
      var baseHeightT=$(e).parents('.allEvidence').offset().top - 161;
        $('.createEvidence').css("top",baseHeightT);

        $('.createEvidence').fadeIn();
        $(e).parents('.editStageEvid').css('display','none');


        $scope.addOrUpdataName = '2';

        $scope.addEGTitle = name;
        $scope.addEGText = disp;
    };

    //删除组
    $scope.deleteEGroup = function ($event, id, num) {
        var $event = $event.target;
        var e = $($event);

        $scope.deleteEGroupId = id;

        $(e).parents('.updateBox').css('display', 'none');

    };

    $scope.deleteEGroupConfirm = function () {
        $rootScope.loadingShow = true;
        $rootScope.fadeShow = true;
        caseBarDetailZhengService.deleteEGroup($scope.deleteEGroupId,$scope.loginId).then(function (data) {
            $rootScope.loadingShow = false;
            $rootScope.fadeShow = false;
            if (data.code == 1) {
              $('#myZhengDelete').css('display',"block");
              $scope.deleteMsg=data.msg;
                //刷新证据组列表
                $scope.getEGroupList();
                $('#deleteEGroup').modal('hide');
            }else if(data.code == 0){
              $('#myZhengDelete').css('display',"block");
              $scope.deleteMsg=data.msg;
              //刷新证据组列表
              $scope.getEGroupList();
              $('#deleteEGroup').modal('hide');
            }

        });
    };

    $scope.deleteEGroupButHaveRConfirm = function () {
      $('#deleteEGroupButHaveE').modal('hide');
      $scope.deleteEGroupConfirm();
    };

  $scope.deleteGroupClose = function () {
    $('#myZhengDelete').css('display',"none");
  };


    //点击取消
    $scope.deleteCancelConfirm = function () {
        $('#deleteEGroupButHaveE').modal('hide');
        $('#deleteEGroup').modal('hide');
    };
//
    /**
     * 日期选择器
     */
    // $(".form_datetime").datetimepicker({
    //     minView: "month",
    //     format: 'yyyy-mm-dd',
    //     language: "zh-CN",
    //     charset: "utf-8"
    // });

    /**
     * 更改日期事件
     */
    // $('.form_datetime')
    //     .datetimepicker()
    //     .on('changeDate', function (ev) {
    //
    //         $('.form_datetime').datetimepicker('hide');
    //         var d = new Date(ev.date);
    //         var a = d.getFullYear() + '-' + (d.getMonth() + 1) + '-' + d.getDate();
    //
    //         caseBarDetailZhengService.updateEDDate($scope.evidenceID, $scope.loginId, a).then(function (data) {
    //             if (data.code == 1) {
    //                 //刷新证据的详情的信息
    //                 $scope.evidenceDetailShow($scope.evidenceID);
    //             }
    //         });
    //
    //     });

    //下载证据清单
    $('.downLoad2Excel').click(function () {
        $(".table2excel").table2excel({
            exclude: ".ztitleName",
            name: "Excel Document Name",
            filename: "证据清单",
            fileext: ".xls",
            exclude_img: true,
            exclude_links: true,
            exclude_inputs: true
        });
    });

    // 打印证据清单
    $('.preview2LLQ').click(function () {
       bdhtml=window.document.body.innerHTML;
        sprnstr="<!--startprint-->";
        eprnstr="<!--endprint-->";
        prnhtml=bdhtml.substring(bdhtml.indexOf(sprnstr)+17);
        prnhtml=prnhtml.substring(0,prnhtml.indexOf(eprnstr));
        window.document.body.innerHTML=prnhtml;
        window.print();
    });

    $('.zqbody').click(function () {

        if($('.rightComeToZJ').css('right')=='0px'){

            $('.rightComeToZJ').animate({
                "right": "-700"
            }, 300);
        }
    });

    $scope.closeEvidence = closeEvidence;
    $scope.openEvidence = openEvidence;

    $scope.showParams = {
      evidenceAll:false,
    };
    //打开导出证据弹窗
  function openEvidence() {
    $scope.showParams.evidenceAll = true;
    $scope.showEAllList();
  }
    //关闭弹窗
  function closeEvidence() {
    $scope.showParams.evidenceAll = false;
  }

  //点击编辑
  $scope.showAddBox = function ($event) {
    $('.zqNewGreat').css('display','none');
    var $a = $($event.target);
    $($a).parents('.newAdd').siblings('.zqNewGreat').css('display','block');
  };

  //失焦关闭
  $("*").click(function () {
    $('.editStageEvid').css('display','none');
  })
  //清除
  $scope.clearForm = function(form) {

    // 迭代input清空
    $(':input', form).each(function () {
      var type = this.type;
      var tag = this.tagName.toLowerCase(); // normalize case
      if (type == 'text' || type == 'password' || tag == 'textarea')
        this.value = "";
      // 跌代多选checkboxes
      else if (type == 'checkbox' || type == 'radio')
        this.checked = false;
      // select 迭代下拉框
      else if (tag == 'select' && $scope.evidenceGroupId == 1){
        //this.selectedIndex = -1;
        $scope.evidenceGroupId = 2;
      }

    });
    $scope.ETypeSelectI=false;
    $scope.quickAddInputT=false;
    $scope.EGroupListI=false;
    $scope.quickAddInput='';
    $scope.ETypeSelect.id=0;
  };

};
